package basic_1006;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner=new Scanner(System.in);
		
		String A=scanner.next();
		char Da=(char) ('0'+scanner.nextInt());
		String B=scanner.next();
		char Db=(char) ('0'+scanner.nextInt());
		scanner.close();
		
		String PA=P(A,Da);
		String PB=P(B,Db);
		if(PA.length()<10&&PB.length()<10) {
			System.out.println(Integer.parseInt(PA)+Integer.parseInt(PB));
		}else {
			System.out.println(add(PA, PB));
		}
	
	}
	
	static String P(String A,char d) {
		String pString="";
		for(char c:A.toCharArray()) {
			if(c==d) {
				pString+=c;
			}
		}
		if(pString.length()==0) {
			pString="0";
		}
		return pString;
	}
	
	static String add(String a,String b) {
		int lenA=a.length();
		int lenB=b.length();
		String A=a,B=b;
		if(lenA<lenB) {
			for(int i=0;i<lenB-lenA;i++) {
				A="0"+A;
			}
			lenA=lenB;
		}else if(lenA>lenB) {
			for(int i=0;i<lenA-lenB;i++) {
				B="0"+B;
			}
			lenB=lenA;
		}
		int flag=0;String C="";
		for(int i=lenA-1;i>=0;i--) {
			int ai=Integer.parseInt(""+A.charAt(i));
			int bi=Integer.parseInt(""+B.charAt(i));
			int ci=ai+bi+flag;
			C=""+ci%10+C;
			flag=ci/10;
		}
		if(flag>0) {
			C=""+flag+C;
		}
		
		return C;
	}
	
}
